/*
 * @Author: WangZhongDe
 * @Date: 2021-08-29 19:34:29
 * @LastEditors: WangZhongDe
 * @LastEditTime: 2021-08-29 20:44:53
 * @FilePath: \rust\learn7\src\lib.rs
 */

pub  trait Summary{
    fn summarize(&self)->String;
    fn default(&self) -> String{
        format!("Read more from {}...",self.summarize())
    }
}
pub struct NewsArticle{
    pub headline:String,
    pub location:String,
    pub author:String,
    pub content:String,
}
impl Summary for NewsArticle{
    fn summarize(&self)->String{
        format!("{} ,by {}  ({})",self.headline,self.author,self.location)
    }
}
pub struct Tweet{
    pub username:String,
    pub content:String,
    pub reply:bool,
    pub retweet:bool,
}
impl Summary for Tweet{
    fn summarize(&self) ->String{
        format!("{};{}",self.username,self.content)
    }
}